package com.eastedu.controller;

import com.eastedu.model.RequestParameter;
import com.eastedu.service.DataSourceService;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 试题来源中应用者为空的数据同步更新
 *
 * @author 张志帅
 */
@RestController
@RequestMapping(value = "/api/v1/question-source/data-sync")
public class QuestionSourceDataSyncController {

    private final DataSourceService dataSourceService;

    /**
     * Instantiates a new Question source data sync controller.
     *
     * @param questionProviderDataSourceServiceImpl the question provider data source service
     */
    public QuestionSourceDataSyncController(DataSourceService questionProviderDataSourceServiceImpl) {
        this.dataSourceService = questionProviderDataSourceServiceImpl;
    }

    /**
     * Question sync http entity.
     *
     * @param parameter the parameter
     * @return the http entity
     */
    @PostMapping
    public HttpEntity<Boolean> questionSync(RequestParameter parameter) {
        this.dataSourceService.sync(parameter);
        return ResponseEntity.ok(true);
    }

}
